home *** CD-ROM | disk | FTP | other *** search
/ World of Video / World of Video.iso / gfxprograms / 3dprograms / rayshade-4.0 / fixes / fix017 / libshade.patch next >
Text File  |  1995-02-13  |  7KB  |  264 lines

  1. diff -c libshade/Makefile.SH libshade/Makefile.SH
  2. *** libshade/Makefile.SH    Sun Feb  9 22:03:46 1992
  3. --- libshade/Makefile.SH    Wed Feb 16 15:52:11 1994
  4. ***************
  5. *** 57,66 ****
  6.   LIB = libshade.a
  7.   
  8.   SUPPORT_C =    builtin.c symtab.c misc.c lightdef.c objdef.c options.c \
  9. !         stats.c surfdef.c
  10.   
  11.   SUPPORT_H =    ../config.h datatypes.h funcdefs.h \
  12. !         ../patchlevel.h rayshade.h
  13.   
  14.   PARSE_C =    yacc.c lex.c
  15.   
  16. --- 57,66 ----
  17.   LIB = libshade.a
  18.   
  19.   SUPPORT_C =    builtin.c symtab.c misc.c lightdef.c objdef.c options.c \
  20. !         stats.c surfdef.c zbuf.c
  21.   
  22.   SUPPORT_H =    ../config.h datatypes.h funcdefs.h \
  23. !         ../patchlevel.h rayshade.h zbuf.h
  24.   
  25.   PARSE_C =    yacc.c lex.c
  26.   
  27. diff -c libshade/misc.c libshade/misc.c
  28. *** libshade/misc.c    Sun Feb  9 22:03:59 1992
  29. --- libshade/misc.c    Wed Feb 16 15:42:42 1994
  30. ***************
  31. *** 36,42 ****
  32. --- 36,46 ----
  33.   #endif
  34.   #include "options.h"
  35.   #include "stats.h"
  36. + #include "libcommon/common.h"
  37. + #include "viewing.h"
  38. + #include "zbuf.h"
  39.   
  40.   Float RSabstmp;    /* Temporary value used by fabs macro.  Ugly. */
  41.   static void RSmessage();
  42.   
  43. ***************
  44. *** 88,93 ****
  45. --- 92,99 ----
  46.        * Initialize symbol table.
  47.        */
  48.       SymtabInit();
  49. +     if (Options.zbufprint)
  50. +         zbuffer.rayfile = strsave (yyfilename);
  51.       (void)yyparse();
  52.   }
  53.   
  54. diff -c libshade/options.c libshade/options.c
  55. *** libshade/options.c    Sun Feb  9 22:04:09 1992
  56. --- libshade/options.c    Wed Feb 16 15:43:00 1994
  57. ***************
  58. *** 239,244 ****
  59. --- 239,264 ----
  60.                   Options.crop_set = TRUE;
  61.                   argv += 4; argc -= 4;
  62.                   break;
  63. +                         case 'z':
  64. +                 Options.zbufprint = TRUE;
  65. +                 if (argv[1][0] == '-') {
  66. +                     /* User probably blew it, and
  67. +                      * it's difficult to remove a file
  68. +                      * that begins with '-'...
  69. +                      */
  70. +                     usage();
  71. +                     exit(2);
  72. +                 }
  73. +                 if (argv[0][2])
  74. +                     Options.zbufname = strsave (argv[0]+2);
  75. +                 else if (argv[1]) {
  76. +                     Options.zbufname = strsave(argv[1]);
  77. +                     argv++; argc--;
  78. +                 } else {
  79. +                     usage();
  80. +                     exit(2);
  81. +                 }
  82. +                 break;
  83.               default:
  84.                   RLerror(RL_PANIC,"Bad argument: %s\n",argv[0]);
  85.           }
  86. ***************
  87. *** 334,337 ****
  88. --- 354,358 ----
  89.       fprintf(stderr,"\t-v \t\t(Verbose output.)\n");
  90.       fprintf(stderr,"\t-W x x y y \t(Render subwindow.)\n");
  91.       fprintf(stderr,"\t-X l r b t \t(Crop window.)\n");
  92. +         fprintf(stderr,"\t-z filename\t(Write Z buffer to filename.)\n");
  93.   }
  94. diff -c libshade/options.h libshade/options.h
  95. *** libshade/options.h    Sun Feb  9 22:03:53 1992
  96. --- libshade/options.h    Wed Feb 16 15:46:56 1994
  97. ***************
  98. *** 69,75 ****
  99.           endframe,        /* ending frame number */
  100.           totalframes,        /* total # of frames */
  101.           totalframes_set,    /* set on command line? */
  102. !         cpp;            /* run CPP? */
  103.   #ifdef URT
  104.       int    alpha;            /* Write alpha channel? */
  105.       int    exp_output;        /* Write exponential RLE file? */
  106. --- 69,76 ----
  107.           endframe,        /* ending frame number */
  108.           totalframes,        /* total # of frames */
  109.           totalframes_set,    /* set on command line? */
  110. !         cpp,            /* run CPP? */
  111. !             zbufprint;              /* print Zbuf stats? */
  112.   #ifdef URT
  113.       int    alpha;            /* Write alpha channel? */
  114.       int    exp_output;        /* Write exponential RLE file? */
  115. ***************
  116. *** 88,94 ****
  117.           *statsname,        /* Name of stats file. */
  118.           *imgname,        /* Name of output image file */
  119.           *inputname,        /* Name of input file, NULL == stdin */
  120. !         *cppargs;        /* arguments to pass to cpp */
  121.       int    window[2][2];        /* Subwindow corners */
  122.       Float    crop[2][2];        /* Crop window, lo/hi normalized */
  123.   #ifdef LINDA
  124. --- 89,96 ----
  125.           *statsname,        /* Name of stats file. */
  126.           *imgname,        /* Name of output image file */
  127.           *inputname,        /* Name of input file, NULL == stdin */
  128. !                 *cppargs,               /* arguments to pass to cpp */
  129. !                 *zbufname;              /* Name of Z buffer file (if any) */
  130.       int    window[2][2];        /* Subwindow corners */
  131.       Float    crop[2][2];        /* Crop window, lo/hi normalized */
  132.   #ifdef LINDA
  133. diff -c libshade/picture.c libshade/picture.c
  134. *** libshade/picture.c    Sun Feb  9 22:04:06 1992
  135. --- libshade/picture.c    Tue Feb 22 23:49:52 1994
  136. ***************
  137. *** 33,38 ****
  138. --- 33,39 ----
  139.   #include "viewing.h"
  140.   #include "options.h"
  141.   #include "stats.h"
  142. + #include "zbuf.h"
  143.   
  144.   #ifdef URT
  145.   unsigned char **outptr;        /* Output buffer */
  146. ***************
  147. *** 131,136 ****
  148. --- 132,143 ----
  149.             * lots of headers at the end of the file).
  150.             */
  151.           (void)fflush(rle_dflt_hdr.rle_file);
  152. +     }
  153. +     if (Options.zbufprint) {
  154. +         zbuffer.outfile = Options.imgname ?
  155. +         strsave (Options.imgname) : NULL;
  156. +         zbuffer.argv = argv;
  157.       }
  158.   
  159.       if (rle_row_alloc(&rle_dflt_hdr, &outptr) < 0)
  160. diff -c libshade/setup.c libshade/setup.c
  161. *** libshade/setup.c    Sun Feb  9 22:04:02 1992
  162. --- libshade/setup.c    Wed Feb 16 15:44:12 1994
  163. ***************
  164. *** 114,119 ****
  165. --- 114,122 ----
  166.       Options.workers = WORKERS;
  167.   #endif
  168.   
  169. +     Options.zbufprint = FALSE;
  170. +     Options.zbufname = NULL;
  171.       Options.totalframes = 1;
  172.       Options.startframe = 0;
  173.       Options.starttime = 0.;
  174. ***************
  175. *** 192,197 ****
  176. --- 195,202 ----
  177.   
  178.   
  179.       LightSetup();
  180. +     if (Options.zbufprint)
  181. +         ZbufSetup();
  182.   }
  183.   
  184.   void
  185. diff -c libshade/stats.c libshade/stats.c
  186. *** libshade/stats.c    Sun Feb  9 22:04:00 1992
  187. --- libshade/stats.c    Wed Feb 16 15:44:54 1994
  188. ***************
  189. *** 86,91 ****
  190. --- 86,93 ----
  191.           fprintf(Stats.fstats,"Seconds / intersecting ray:\t%4.4f\n",
  192.               (Stats.Utime + Stats.Stime)/(Float)Stats.HitRays);
  193.       PrintMemoryStats(Stats.fstats);
  194. +     if (Options.zbufprint)
  195. +         ZbufPrint();
  196.   }
  197.   
  198.   static void
  199. diff -c libshade/viewing.c libshade/viewing.c
  200. *** libshade/viewing.c    Sun Feb  9 22:04:10 1992
  201. --- libshade/viewing.c    Thu Feb 24 21:39:06 1994
  202. ***************
  203. *** 30,35 ****
  204. --- 30,36 ----
  205.   #include "defaults.h"
  206.   #include "picture.h"
  207.   #include "stats.h"
  208. + #include "zbuf.h"
  209.   
  210.   RSCamera    Camera;
  211.   RSScreen    Screen;
  212. ***************
  213. *** 89,94 ****
  214. --- 90,98 ----
  215.       Screen.firstray.z -= 0.5*Screen.yres*Screen.scrny.z +
  216.                    0.5*Screen.xres*Screen.scrnx.z;
  217.   
  218. +     /* Firstray now points to the lower left corner of the image plane,
  219. +        if fixed at the eye position */
  220.       if (Camera.focaldist == UNSET)
  221.           Camera.focaldist = Camera.lookdist;
  222.   }
  223. ***************
  224. *** 281,293 ****
  225.       dist = FAR_AWAY;
  226.       hitlist.nodes = 0;
  227.       (void)TraceRay(ray, &hitlist, EPSILON, &dist);
  228.       ShadeRay(&hitlist, ray, dist, &Screen.background, &ctmp, &fullintens);
  229.       color->r = ctmp.r;
  230.       color->g = ctmp.g;
  231.       color->b = ctmp.b;
  232. !     if (hitlist.nodes != 0) {
  233. !         color->alpha = 1.;
  234. !     } else {
  235. !         color->alpha = 0.;
  236.       }
  237.   }
  238. --- 285,305 ----
  239.       dist = FAR_AWAY;
  240.       hitlist.nodes = 0;
  241.       (void)TraceRay(ray, &hitlist, EPSILON, &dist);
  242.       ShadeRay(&hitlist, ray, dist, &Screen.background, &ctmp, &fullintens);
  243.       color->r = ctmp.r;
  244.       color->g = ctmp.g;
  245.       color->b = ctmp.b;
  246. !     if (hitlist.nodes != 0) 
  247. !     {
  248. !         Float d = hitlist.data[hitlist.nodes-1].dist;
  249. !         d *= dotp(&Camera.dir, &hitlist.data[hitlist.nodes-1].ray.dir);
  250. !         ZbufAdd (x, y, d); /* Save depth in Z buffer */
  251. !         color->alpha = 1.;
  252. !     }
  253. !     else 
  254. !     {
  255. !         color->alpha = 0.;
  256.       }
  257.   }
  258.